﻿#ifndef GPLAYER_H
#define GPLAYER_H

#include <QMainWindow>
#include <QSystemTrayIcon>
#include <QListWidget>

#include <QMediaPlayer>
#include <QMediaPlaylist>

QT_BEGIN_NAMESPACE
namespace Ui { class GPlayer; }
QT_END_NAMESPACE

class GPlayer : public QMainWindow
{
    Q_OBJECT

public:
    GPlayer(QWidget *parent = nullptr);
    ~GPlayer();

    void closeEvent(QCloseEvent *event); // 重载关闭按钮
    void mousePressEvent(QMouseEvent *event);
private:
    Ui::GPlayer *ui;

    void initTrayMenu();
    void initConnect();

    void clickDoubleListItem(QListWidgetItem *item);
    void customContextMenuRequestedList(const QPoint &pos);

    void clickAddSong();
    void clickPalyMode();
    void clickSetVol();
    void clickPlay();
    void clickPrevious();
    void clickNext();

    void showOption();
    void showAbout();

    void updatePosition(qint64 position);
    void updateDuration(qint64 duration);
    void updateCurrentIndex(int index);

    QSystemTrayIcon* m_pSystemTray;     // 系统托盘图标
    QMenu* m_pTrayMenu;                 // 托盘图标

    QVector<QString> m_vPalyMode;
    int m_iPlayMode;


    QMediaPlayer  *m_music;
    QMediaPlaylist *m_playlist;
};
#endif // GPLAYER_H
